package com.itheima.patterns.builderpattern.prototype.deepcopy;

import java.io.*;

public class Client {
    public static void main(String[] args) throws Exception {
        Person person1 = new Person(1,"小华",new Address(1,"北京"));
    
        //创建对象输出流对象
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("E:\\testData\\a.txt"));
        //写对象
        oos.writeObject(person1);
        //释放资源
        oos.close();
    
        //创建对象输入流对象
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("E:\\testData\\a.txt"));
        //读取对象
        Person person2 = (Person) ois.readObject();
        //释放资源
        ois.close();
        
        System.out.println("person1:"+person1);
        System.out.println("person2:"+person2);
        System.out.println("person1.getName() == person2.getName()的结果为："+(person1.getName() == person2.getName()));
        System.out.println("person1 == person2的结果为："+(person1 == person2));
    }
}